package com.ncloud.resman.controller;

import com.alibaba.fastjson.JSONObject;
import com.ncloud.common.body.Result;
import com.ncloud.common.utils.ResultUtil;
import com.ncloud.resman.service.impl.DeviceMapServiceImpl;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by gaowei on 2017/8/15.
 */
@RestController
@RequestMapping("/resman/map")
public class DeviceMapController {
	@Autowired
	private DeviceMapServiceImpl deviceMapService;
    @GetMapping(value = "/base/{roomId}/{cabinetId}")
    public Result<?> getDeviceMapBase(HttpServletRequest request,
    		@PathVariable("roomId") Integer roomId,@PathVariable("cabinetId") Long cabinetId){
    	JSONObject params = new JSONObject();
    	params.put("roomId", roomId);
    	params.put("cabinetId", cabinetId);
    	JSONObject infos = deviceMapService.getDeviceMapBase(params);
		return ResultUtil.success(infos);
    }
    @GetMapping(value = "/server/{deviceId}")
    public Result<?> getDeviceMapServer(HttpServletRequest request,@PathVariable("deviceId") Long deviceId){
    	JSONObject params = new JSONObject();
    	params.put("deviceId", deviceId);
    	JSONObject infos = deviceMapService.getDeviceMapServer(params);
		return ResultUtil.success(infos);
    }
    @GetMapping(value = "/switch/{deviceId}")
    public Result<?> getDeviceMapSwitch(HttpServletRequest request,@PathVariable("deviceId") Long deviceId){
    	JSONObject params = new JSONObject();
    	params.put("deviceId", deviceId);
    	JSONObject infos = deviceMapService.getDeviceMapSwitch(params);
		return ResultUtil.success(infos);
    }
    @GetMapping(value = "/firewall/{deviceId}")
    public Result<?> getDeviceMapFirewall(HttpServletRequest request,@PathVariable("deviceId") Long deviceId){
    	JSONObject params = new JSONObject();
    	params.put("deviceId", deviceId);
    	JSONObject infos = deviceMapService.getDeviceMapFirewall(params);
		return ResultUtil.success(infos);
    }
}
